<style scoped lang="scss">
  @import '@/assets/css/index';
  .fans{
    @include pageBottom();
    .fans-data-box{
      background-color: white;
      .data-title{
        font-size: 1.6rem;
        font-weight: bold;
      }
      .fans-info{
        display: flex;
        align-items: center;
        margin-top: 1.6rem;
        .box-item{
          flex: 1;
          // margin-top: 1.8rem;
          .cap-title{
            color: $color-subtitle;
            font-size: 1.4rem;
          }
          .num{
            margin-top: 0.8rem;
            font-size: 1.5rem;
            font-weight: bold;
          }
        } 
      }
    }
    .activity-list{
      background-color: white;
      .title{
        font-size: 1.6rem;
        font-weight: bold;
      }
      .list{
        .item{
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding-top: 1rem;
          padding-bottom: 1rem;
          border-bottom: 1px solid $border-c;
          .icon{
            flex: 0 0 3rem;
            text-align: right;
          }
          .content{
            display: flex;
            flex-direction: column;
            justify-content: space-around;
          }
        }
      }
    }
  }
</style>
<template>
  <div class="fans padding-all-l">
    <!-- <div class="title title-m">活动粉丝总览</div> -->
    <div class="fans-data-box padding-all-l border-r-l">
      <div class="data-title">活动粉丝总览</div>
      <div class="fans-info">
        <div class="box-item">
          <div class="cap-title">访问次数</div>
          <div class="num color-red">{{fansInfo.browse_num}}</div>
        </div>
        <div class="box-item">
          <div class="cap-title">参与量</div>
          <div class="num color-green">{{fansInfo.join_num}}</div>
        </div>
      </div>
    </div>
    <div class="activity-list padding-all-l margT-l border-r-l">
      <div class="title "><span :style="{color:$store.getters.getMasterColor}">进行中</span>的活动</div>
      <div class="list" v-if="list&&list.length>0">
        <div class="item" v-for="item in list" :key="item.id" @click="toView(item)">
          <div class="content">
            <span class="title-s">{{item.title}}</span>
            <span class="time margT-m">创建时间 {{item.createtime}}</span>
          </div>
          <span class="icon"><van-icon name="arrow" color="#999"/></span>
        </div>
      </div>
      <div class="no-data padding-all-l color-s"  v-else>当前没有正在进行中的活动</div>
    </div>
    <div class="tabbar-height"></div>
  </div>
</template>

<script>
// @ is an alias to /src
import { Icon, Toast } from 'vant'
import {myMixins} from "@/assets/js/mixins.js"
export default {
  name: "Fans",
  mixins: [myMixins],
  components: {
    [Icon.name]: Icon
  },
  data () {
    return {
      openid:'',
      fansInfo:{},
      list:[],
      pageNo: 1,
      pageSize: 10,
    }
  },
  mounted() {
    this.openid = this.$store.state.openid
    this.getActivityFans()
    this.list = this.$store.state.activityStatus1
    console.log("list", this.list)
    if(!this.list){
      this.getActivityPage()
    }
    this.toHome()
    this.configItemShare()
  },
  methods: {
    getActivityPage() {
      const _this = this;
      let params = {
        openid: _this.$store.state.openid, // _this.$store.state.openid
        status: 1,
        pageNo: _this.pageNo,
        pageSize: _this.pageSize
      }
      const toast = Toast.loading({
          forbidClick: true,
          message: '加载中...',
      });
      console.log(params,"params")
      _this.$request.getActivityPage(params).then(res=>{
        let data = res.data.data
        _this.list = data
        _this.$store.commit('setActivityStatus1',data)
        toast.clear()
      })
    },
    toView(item){
      const activityData = {
        id:item.id,
        title:item.title,
        createTime: item.createtime,
        browse_num: item.browse_num,
        join_num: item.join_num
      }
      this.$store.commit('setActivityData', activityData)
      this.$router.push('/fans/activityFans/' + item.id)
    },
    getActivityFans() {
      let params = {
        openid: this.openid
      }
      console.log("params", params)
      this.$request.getActivityFans(params).then(res=>{
        console.log('res', res)
        this.fansInfo = res.data
      })
    }
  }
};
</script>
